package com.kele.controller;

import com.kele.domain.Blog;
import com.kele.domain.Collections;
import com.kele.service.BlogService;
import com.kele.service.CollectionService;
import com.kele.utils.ResponseData;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

@Controller
public class JudgeCollectionController {
    @Resource
    CollectionService collectionService;
    @Resource
    BlogService blogService;
@RequestMapping(value = "/judgeCollection",method = RequestMethod.GET)
@ResponseBody
    public ResponseData judgeCollection(int blogid, int userid){
    Collections collections=collectionService.findCollection(blogid, userid);
    Blog blog=blogService.findBlogById(blogid);
    System.out.println(collections);
    if(collections!=null){
        return ResponseData.success("1",blog.getCollection());
    }else{
        return ResponseData.success("0",blog.getCollection());
    }

}
}
